package com.lz.football.module.activity.timelimitDiscount
{
	import com.common.utils.Reflection;
	import com.liangzhong.model.activity.ActivityTimeLimitVo;
	import com.liangzhong.model.goods.vo.GoodsVo;
	import com.lz.football.module.base.IComponent;
	
	import flash.display.Bitmap;
	import flash.display.MovieClip;
	import flash.display.SimpleButton;
	import flash.display.Sprite;
	import flash.events.MouseEvent;

	/**
	 *限时打折购买item
	 *  
	 * @author Administrator
	 * 
	 */	
	public class TimelimiteBuyItem extends Sprite implements IComponent
	{
		/**
		 *皮肤 
		 */
		public var _skin:MovieClip;
		
		

		private var _callBack:Function;
		/**
		 *购买按钮 
		 */
		private var buyBtn:SimpleButton;
		/**
		 * 
		 */
		private var _goodVo:ActivityTimeLimitVo;
		public function TimelimiteBuyItem()
		{
			super();
		}
		
		public function initUI(view:Object=null):void
		{
			_skin = Reflection.createInstance("com.lz.res.activity.timelimit.buyItem");
			this.addChild(_skin);
			buyBtn = _skin.buyBtn;
			addEvtListener();
		}
		
		public function addEvtListener():void
		{
			buyBtn.addEventListener(MouseEvent.CLICK,onBuyHanlder);
		}
		/**
		 *设置数据 
		 * @param $vo
		 * 
		 */
		public function setDate($vo:ActivityTimeLimitVo):void
		{
			_goodVo = $vo;
			
			_skin.goodName.text = "" + _goodVo.goodsVo.name;
			_skin.originalPrice.text = "" + $vo.price1;
			_skin.currentPrice.text = "" + $vo.price2;
			var contain:MovieClip = _skin.image;
			contain.addChild(new Bitmap(_goodVo.goodsVo.bitmapData));
		}
		
		protected function onBuyHanlder(event:MouseEvent):void
		{
			// TODO Auto-generated method stub
			if(_callBack != null)_callBack(_goodVo);
		}
		
		public function removeEvtListener():void
		{
			buyBtn.removeEventListener(MouseEvent.CLICK,onBuyHanlder);
		}
		
		public function destroyView():void
		{
			_callBack = null;
			removeEvtListener();
		}
		public function set callBack(value:Function):void
		{
			_callBack = value;
		}
	}
}